<template>
  <div>
    <van-search
      v-model="value"
      show-action
      placeholder="请输入小区或地址"
      @search="onSearch"
      @cancel="onCancel"
    />

    <div class="article-page">
      <div class="article-item" v-for="item in info" :key="item.id">
        <div class="left">
          <img :src="item.houseImg" alt="图片加载失败" />
        </div>
        <div class="body">
          <h2>{{ item.price }}</h2>
          <p class="p1">{{ item.desc }}</p>
          <span>{{ item.tags[0] }}</span>
          <p class="p2">{{ item.price }}</p><p class="p3">元/月</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import axios from 'axios';

export default {
  name: 'Zhaofang',
  data() {
    return {
      info: null,
    };
  },
  methods: {
    // toDetail(id) {
    //   this.$router.push({
    //     name:"detail",
    //     //路由传参
    //     query:{
    //       id
    //     }
    //   })
    // }
  },
  async created() {
    const { data } = await axios('http://liufusong.top:8080/houses');
    console.log(data);
    this.info = data.body.list;
  },
};
</script>

<style scoped lang="less">
.article-item {
  display: flex;
  align-content: space-between;
  border-bottom: 1px solid #ccc;
}
.left {
  // border: 2px solid red;
  width: 120px;
}
.body {
  position: relative;
  // border: 2px solid red;
  height: 100px;
  width: 250px;
  h2 {
    font-size: 15px;
    position: absolute;
    left: 5px;
    top: 0px;
  }
  span {
    display: inline-block;
    background-color: #e1f5f8;
    color:#39becd;
    width: 50px;
    height: 20px;
    line-height: 20px;
    font-size: 12px;
    position: absolute;
    left: 5px;
    top: 55px;
  }
}
.p1 {
  font-size: 12px;
  color: #afb2b3;
  position: absolute;
  left: 5px;
  top: 20px;
}
.p2 {
  position: absolute;
    left: 5px;
    top: 62px;
    color:#fa5741;
    font-size: 16px;
    font-weight: 700;
}
.p3{
   position: absolute;
    left: 40px;
    top: 66px;
    color:#fa5741;
     font-size: 12px;
}
</style>
